package com.ljw.spring.annotation.bean;

import org.springframework.beans.BeansException;
import org.springframework.context.ApplicationContext;
import org.springframework.context.ApplicationContextAware;

/**
 * @FileName Boat
 * @Description TODO
 * @Author ljw
 * @Date 2021/2/1 23:53
 * @Version 1.0
 */

/**
 * 一个类实现接口ApplicationContextAware，重写方法setApplicationContext(ApplicationContext applicationContext)，
 * 则这个实现类在实例化后初始化前会执行 ApplicationContextAwareProcessor 类中的方法
 * postProcessBeforeInitialization(Object bean, String beanName)和invokeAwareInterfaces(Object bean)
 * 来导入IOC容器====》ApplicationContext
 */
public class Boat implements ApplicationContextAware{

    private ApplicationContext applicationContext;


    //导入IOC容器
    @Override
    public void setApplicationContext(ApplicationContext applicationContext) throws BeansException {
        //设置IOC容器的值
        this.applicationContext=applicationContext;
    }
}
